<?php

/**
 * Created by PhpStorm.
 * User: Vito
 * Date: 2022/3/15
 * Time: 17:18
 */

use app\admin\middleware\AdminAuthTokenMiddleware;
use app\admin\middleware\AdminCheckAuthMiddleware;
use app\common\ErrorCode;
use think\facade\Route;

Route::group('<api_version>', function () {
    //仪表盘
    Route::group('dashboard', function () {
        Route::get('', 'index');
        Route::get('getAllCabinet', 'getAllCabinet');
    })->prefix('Dashboard/');
    Route::group('attachment', function () {
        Route::post('importWaterEleExcel', 'importWaterEleExcel');
        Route::post('importUserExcel','importUserExcel');
        Route::post('importRoomExcel','importRoomExcel');
    })->prefix('Attachment/');
    Route::resource('attachment', 'Attachment');
    //管理员
    Route::group('admin', function () {
        //个人信息
        Route::get('info', 'info');
    })->prefix('Admin/');
    Route::resource('admin', 'Admin');
    //更新个人信息接口
    Route::put('profile', 'Profile/update');
    //广告
    Route::resource('adverts', 'Adverts');
    //维护员
    Route::resource('repair_user', 'RepairUser');
    //通联支付
    Route::resource('all_in_pay', 'AllInPay');
    //设备
    Route::group('device', function () {
        Route::get('state', 'state');
    })->prefix('Device/');

    Route::resource('device', 'Device');
    //订单
    Route::group('order', function () {
        //退款申请
        Route::post('refund', 'refund');
    })->prefix('Order/');
    Route::resource('order', 'Order');
    //套餐
    Route::resource('product', 'Product');

    //权限
    Route::group('system_auth', function () {
        //刷新权限
        Route::post('flush', 'flush');
    })->prefix('SystemAuth/');
    //资源路由放后面
    Route::resource('system_auth', 'SystemAuth');

    //配置
    Route::put('system_config/config', 'SystemConfig/config');
    Route::resource('system_config', 'SystemConfig');
    //配置分类
    Route::resource('system_config_tab', 'SystemConfigTab');
    //日志类
    Route::resource('system_log', 'SystemLog')->only(['index', 'delete', 'read']);

    //角色
    Route::group('system_role', function () {
        //获取菜单
        Route::get('menu', 'menu');
        //获取权限
        Route::get('role', 'role');
    })->prefix('SystemRole/');
    Route::resource('system_role', 'SystemRole');

    //用户
    Route::resource('user', 'User');
    //用户第三方授权
    Route::resource('user_oauth', 'UserOauth');

    //小区
    Route::group('housing', function () {
        //获取菜单
        Route::get('test', 'aaaa');
        //获取权限
        // Route::get('role', 'role');
    })->prefix('Housing/');

    Route::resource('housing', 'Housing');

    // 楼房
    Route::resource('building', 'Building');

    // 房型管理
    Route::resource('room_type', 'RoomType');

    // 房间管理
    Route::resource('room', 'Room');

    //租房管理
    Route::group('roomLeaseRecord', function () {
        Route::post('allot', 'allot');
        Route::post('removeUser', 'removeUser');
        Route::get('getPaidNumber', 'getPaidNumber');
        Route::post('backRecord', 'backRecord');
        Route::get('saveMessage','saveMessage');
        //获取权限
        // Route::get('role', 'role');
    })->prefix('RoomLeaseRecord/');
    Route::resource('roomLeaseRecord', 'RoomLeaseRecord');

    // 水电管理
    Route::resource('waterElePrice', 'WaterElePrice');

    // 入住管理
    Route::group('check_in', function () {
        Route::get('getLessee', 'getLessee');
        Route::get('getTenantList', 'getTenantList');
        Route::get('getRoomDetail', 'getRoomDetail');
        //获取权限
        // Route::get('role', 'role');
    })->prefix('CheckIn/');
    Route::resource('check_in', 'CheckIn');

    // 退宿记录
    Route::resource('check_out', 'CheckOut');

    // 缴费管理
    Route::group('payRecord', function () {
        Route::get('getHousing', 'getHousing');
        Route::get('getLastReading', 'getLastReading');
        Route::get('getTotal', 'getTotal');
        Route::post('sendWorthMessage', 'sendWorthMessage');
        Route::get('getExportList', 'getExportList');
        Route::get('getWarningTime', 'getWarningTime');
        Route::get('saveWarningTime', 'saveWarningTime');
        Route::post('cashPayProcess','cashPayProcess');
    })->prefix('PayRecord/');
    Route::resource('payRecord', 'PayRecord');

    // 现金缴费管理
    Route::resource('payRecordCopy', 'PayRecordCopy');

    // 巡检类型管理
    Route::group('pollingType', function () {
        
        Route::get('getDetail', 'getDetail');

        Route::post('saveDetail', 'saveDetail');

    })->prefix('PollingType/');
    Route::resource('pollingType', 'PollingType');
    
    // 巡检设备管理
    Route::resource('polling_device', 'PollingDevice');

    // 巡检列表管理
    Route::group('pollingRecord', function () {

        Route::post('getRecordDetail', 'getRecordDetail');

        // Route::post('saveDetail', 'saveDetail');
    })->prefix('PollingRecord/');
    Route::resource('pollingRecord', 'PollingRecord');

    // 报修管理
    Route::group('repair', function () {

        Route::post('allotRepair', 'allotRepair');

        // Route::post('saveDetail', 'saveDetail');
    })->prefix('Repair/');
    Route::resource('repair', 'Repair');

    // 通知管理
    Route::resource('message', 'Message');

    // 新闻管理
    Route::resource('news', 'News');

    // 周边管理
    Route::resource('surrounding', 'Surrounding');

    // 水电列表管理
    Route::group('waterEleRecord', function () {

        Route::get('getWaterEle', 'getWaterEle');

        // Route::post('saveDetail', 'saveDetail');
    })->prefix('WaterEleRecord/');
    Route::resource('waterEleRecord', 'WaterEleRecord');

    //快递柜订单列表
    Route::resource('third_party', 'ThirdParty');
    // 保修评价
    Route::resource('repair_rate','RepairRate');
    
})->prefix('<api_version>.')->middleware([AdminAuthTokenMiddleware::class, AdminCheckAuthMiddleware::class]);

//miss路由
Route::miss(function () {
    return error(ErrorCode::ROUTE_NOT_FOUND);
});
